1. /* sdmtkout.cpp by K.Tsuru */
  2. // function ID 356 DRADIX, BRADIX
  3. /***********************************************************
  4. SDouble, SDecimal class
  5. Ver 1.02
  6. It makes an approximated value taking first "fig" figures.
  7. ************************************************************/
  8. #ifndef SN_H
  9. #include "sn.h"
  10. #endif
  11. SDouble SDouble::TakeOutFigures(uint fig) const{
  12. if(Sign(356) == 0) return SDZero(*this);
  13. uint n_copy = min(fig+aTail, aHead+1u), sz, cm = CurrentMaxSize();
  14. if(n_copy >= cm) n_copy = (Type() == REAL) ? (cm -1u) : cm;
  15. if(Type() == REAL) sz = n_copy;
  16. else sz = MaxSize(); // SDecimal class
  17. SDouble r(Type(), 0);
  18. r.valloc(sz, -1);
  19. fType* rv = r.figure.Elements();
  20. #ifndef NDEBUG
  21. r.figure(n_copy-1);
  22. #endif
  23. memcpy(rv, ReadFigures(), n_copy*sizeof(fType));
  24. r.figure.clear(n_copy);
  25. uint i = 0;
  26. while(!rv[i] && (i < n_copy)) i++;
  27. if((i == n_copy) && !rv[i-1]) return SDZero(*this);
  28. r.aTail = i;
  29. i = n_copy-1;
  30. while(!rv[i]) i--;
  31. r.aHead = i;
  32. r.SetRdxExp(rdxExp);
  33. r.SetSign(Sign());
  34. return r;
  35. }

sdmtkout.cpp : last modifiled at 2017/03/13 14:31:58(1,081 bytes)
created at 2017/10/07 10:21:14
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).